<template>
  <div class="execution">
    <basic-container>
      <el-form ref="dataForm" :model="dataForm"  label-width="150px" size="small">
        <el-form-item label="首页栏简介" prop="info">
          <el-input v-model="dataForm.info" style="width: 400px" :min="1" :max="16" placeholder="请填写简介！">
          </el-input>
        </el-form-item>
        <el-form-item>
          <span>注：最多16字</span>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">保存</el-button>
          <el-button @click="getList()">取消</el-button>
        </el-form-item>
      </el-form>
    </basic-container>
  </div>
</template>

<script>
  import Vue from 'vue'
  import {saveIndexInfoConfig,getIndexInfoConfig} from '@/api/admin/config'

  export default {
    name: 'config',
    data () {
      return {
        dataForm: {},
        headers: {
          'token': Vue.cookie.get('token')
        },
      }
    },
    mounted: function () {
      this.getList()
    },
    methods: {
      getList () {
        getIndexInfoConfig().then(response => {
          this.dataForm = response.data.data
          // if (this.dataForm.sgShareImage) {
          //   getIndexInfoConfig(this.dataForm.sgShareImage).then((res) => {
          //     this.fileList = [{
          //       url: res.data
          //     }]
          //   })
          // }
        })
      },
      /**
       * @title 数据添加
       * @param row 为当前的数据
       * @param done 为表单关闭函数
       *
       **/
      onSubmit () {
        const data = new FormData()
        data.append('paramValue', JSON.stringify(this.dataForm))
        saveIndexInfoConfig(data).then(res => {
          this.$message({
            showClose: true,
            message: '保存成功',
            type: 'success'
          })
          this.getList()
        })
      },
//      /**
//       * 刷新回调
//       */
//      refreshChange() {
//        this.getList(this.page)
//      }
    }
  }
</script>

<style lang="scss" scoped>
</style>
